π§ The Linux Filesystem
Now we learn one of the most important Linux concepts: how Linux organizes everything on your computer.
I'll explain it like you're 5, but we won't dumb down the actual concepts. The goal is for you to eventually look at a cloud server and know exactly where things belong.
π 1. Imagine Linux as a Giant House
Imagine your computer is a giant house.
In Windows, you might see:
C:\
βββ Users
βββ Program Files
βββ Windows
Linux does things differently.
Linux starts from one giant starting point:
/
This is called the root of the filesystem.
Think of / as:
π The main entrance to the entire Linux house.
Everything else lives underneath it.
π³ 2. The Linux Filesystem Tree
A simplified Linux filesystem looks like this:
/
βββ bin
βββ boot
βββ dev
βββ etc
βββ home
βββ lib
βββ media
βββ mnt
βββ opt
βββ proc
βββ root
βββ run
βββ sbin
βββ srv
βββ sys
βββ tmp
βββ usr
βββ var
At first this looks scary.
Don't memorize everything yet.
For cloud engineering, these are particularly important:
/
βββ etc
βββ home
βββ root
βββ tmp
βββ usr
βββ var
βββ dev
βββ proc
βββ opt
Let's understand them one by one.
π 3. / β The Root
The / directory is the top of the filesystem.
For example:
cd /
Now:
pwd
You should get:
/
And:
ls
might show:
bin
boot
dev
etc
home
lib
opt
proc
root
run
sbin
tmp
usr
var
Think:
/
β
βββββββββββββΌββββββββββββ
β β β
home etc var
β
β
user
Everything begins at /.
π‘ 4. /home β Users' Homes
Remember when we used:
cd ~
?
Your ~ points to your user's home directory.
For example:
/home/alex
The structure might look like:
/home
βββ alex
βββ Documents
βββ Downloads
βββ Pictures
βββ cloud
Each normal user generally gets a home directory.
You can check:
cd /home
ls
You might see:
alex
Then:
cd alex
That's your home.
π 5. /root β The Root User's Home
Here's an important distinction:
/
means:
The root of the entire filesystem.
/rootβ
means:
The home directory of the root user.
These are completely different things.
/
βββ root/
Don't confuse:
/
with:
/root
Think:
/= the whole house/root= the administrator's bedroom
βοΈ 6. /etc β Configuration
This directory is extremely important for system administration.
/etc contains system configuration files.
For example:
/etc
βββ hosts
βββ hostname
βββ ssh
βββ systemd
βββ passwd
βββ ...
You can look at it:
ls /etc
You'll see many files and directories.
For example:
cat /etc/hostname
This usually displays your computer's hostname.
You can also inspect:
cat /etc/hosts
We'll learn exactly what that file does when we study networking.
π§ Remember:β
/etc = configuration
When you're troubleshooting a Linux server, you'll visit /etc a lot.
π 7. /var β Things That Change
/var stands for variable data.
Think:
"Stuff that changes while the computer is running."
It contains things such as:
- Logs
- Caches
- Application data
- Spool files
One especially important directory:
/var/log
That's where many Linux logs live.
Try:
ls /var/log
You may see things like:
syslog
auth.log
kern.log
...
The exact files depend on your Linux distribution.
Later, when we learn:
journalctl
and troubleshooting, /var/log will become very important.
π§ Remember:β
/var = changing data
ποΈ 8. /tmp β Temporary Stuff
/tmp is for temporary files.
Imagine your desk.
You put something there temporarily while working on a project.
That's /tmp.
Try:
ls /tmp
You may see various temporary files.
Programs often use /tmp for temporary data.
π§ Remember:β
/tmp = temporary files
Don't treat /tmp as permanent storage.
π§° 9. /usr β User-Space Programs & Data
This one can be confusing.
Historically, /usr was associated with "user" programs/data, but don't think of it simply as "my personal files."
Modern Linux systems commonly have things like:
/usr
βββ bin
βββ sbin
βββ lib
βββ share
βββ local
For example:
ls /usr/bin
You'll see lots of programs.
Your system may have commands such as:
python3
git
curl
grep
ssh
located somewhere under /usr.
You can find where a command comes from with:
which ls
or, on many systems:
which python3
You might get:
/usr/bin/ls
π§ Remember:β
/usr = many installed programs and shared data
π§° 10. /bin β Essential Commands
Historically, /bin contained essential user commands.
For example:
/bin
βββ ls
βββ cp
βββ mv
βββ rm
βββ ...
On many modern Linux distributions, /bin is actually a symbolic link to something like:
/usr/bin
You don't need to worry about that yet.
Just remember:
/binis associated with essential command-line programs.
π§ 11. /sbin β System Administration Commands
Similarly:
/sbin
traditionally contains system-administration programs.
For example, commands related to:
- Networking
- System management
- Filesystems
Modern distributions may also merge /sbin into /usr/sbin.
Again, don't get stuck on the historical details.
Remember:
/bin β general essential commands
/sbin β system administration commands
π§© 12. /dev β Devices
This one is fascinating.
Linux treats many hardware devices like files.
That's why:
/dev
contains device representations.
Try:
ls /dev
You'll see things like:
null
zero
random
tty
...
You might see disks such as:
sda
nvme0n1
depending on the machine.
Why should a cloud engineer care?β
Because cloud servers have:
- Virtual disks
- Block devices
- Network devices
When you're managing storage on a cloud VM, /dev becomes important.
π§ 13. /proc β Information About the Running System
/proc is special.
It isn't a normal directory full of ordinary files sitting on your disk.
Linux creates much of its contents dynamically to expose information about:
- Processes
- Memory
- CPU
- Kernel state
Try:
ls /proc
You'll see many numbers:
1
2
3
...
Those numbers are often process IDs (PIDs).
For example:
cat /proc/cpuinfo
gives information about your CPU.
Try:
cat /proc/meminfo
You'll get memory information.
π§ Remember:β
/proc = information about the running Linux system
This will become extremely useful when we learn process troubleshooting.
πΎ 14. /boot β Boot Files
When a computer starts, Linux needs certain files to boot.
Those are stored under:
/boot
You might see:
vmlinuz...
initramfs...
grub...
You don't need to modify these as a beginner.
Just remember:
/boot = files needed for booting Linux
π¦ 15. /opt β Optional/Additional Software
/opt is commonly used for additional or third-party software.
For example:
/opt/my-application
could contain an application installed outside the standard system locations.
Think:
"Extra software lives here."
π 16. /mnt and /media
These directories are commonly associated with mounting filesystems.
/mntβ
Often used as a temporary/manual mount point.
Example concept:
/mnt/backup
/mediaβ
Commonly used for automatically mounted removable media.
For cloud engineering, you'll eventually need to understand mounting disks, so these directories will make more sense later.
π 17. /srv
/srv can be used for data served by system services.
For example, a server might store certain website/service data under:
/srv
It's less important for you right now than /etc, /var, /home, and /usr.
π§ The Big Cheat Sheet
Don't memorize every directory today.
Memorize this:
| Directory | Think |
|---|---|
/ | π Everything |
/home | π Normal users |
/root | π Root user's home |
/etc | βοΈ Configuration |
/var | π Changing data/logs |
/tmp | ποΈ Temporary files |
/usr | π§° Programs/shared data |
/bin | π§ Essential commands |
/sbin | π οΈ System commands |
/dev | πΎ Devices |
/proc | π§ Running system/process info |
/boot | π Boot files |
/opt | π¦ Optional software |
/mnt | π Mount point |
/media | πΏ Removable media |
/srv | π Service data |
π§ Absolute vs Relative Paths
This is very important.
Suppose you're here:
/home/alex/cloud
And you want:
/home/alex/cloud/linux
You can use:
cd linux
That's a relative path.
You're saying:
"From where I am now, go into
linux."
But you could also write:
cd /home/alex/cloud/linux
That's an absolute path.
You're saying:
"Start at
/and follow this exact path."
π How to Recognize Them
Absolute pathβ
Starts with /:
/home/alex/cloud
/etc/hosts
/var/log
/usr/bin
Relative pathβ
Doesn't start with /:
cloud
linux/notes.txt
../Documents
This distinction is essential when writing scripts and managing servers.
π§ͺ Your Filesystem Lab
Now let's explore your Linux machine.
Run these one at a time:
pwd
Then:
ls /
Then:
ls /home
Then:
ls /etc
Then:
ls /var
Then:
ls /var/log
Then:
ls /usr/bin | head
And finally:
cat /etc/hostname
One particularly important experiment:β
Run:
cd /
Then:
pwd
You should get:
/
Now run:
cd /tmp
Then:
pwd
You should get:
/tmp
Now:
cd ..
Where do you think you are?
Run:
pwd
Don't just guessβpredict first, then run it.
π― Mini Challenge
Without looking back at the explanations, answer these:
- Where are normal users' home directories stored?
- Where would you look for system configuration?
- Where would you look for logs?
- Where are temporary files generally stored?
- What is
/root? - What is
/? - What's the difference between
/home/userandhome/user? - Where can you find information about running processes?
- Where are device representations found?
- What does
..mean?
Once you've done the lab, send me your answers + any command output that surprised you.
Then we'll move to Lesson #3: Linux files, permissions, users, groups, and the mysterious -rwxr-xr-x. That's where you'll start understanding what those weird Linux permission strings actually mean.